/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
package crawler.impl;

import crawler.itf.PostCrawlerItf;
import java.io.IOException;
import org.apache.log4j.Logger;
import org.jsoup.Connection;
import org.jsoup.Jsoup;
import org.jsoup.nodes.Document;

/**
 *
 * @author LT
 */
public class PostCrawlerImpl implements PostCrawlerItf {
    private static final Logger logger = Logger.getLogger(PostCrawlerImpl.class);

    @Override
    public Document getDocument(String url) {
        try {
            Connection cnn = Jsoup.connect(url);
            cnn.header("User-agent", "Mozilla/5.0 (Windows NT 6.1; WOW64; rv:33.0) Gecko/20100101 Firefox/33.0");
            Document doc = cnn.get();
            return doc;
        } catch (IOException ex) {
            logger.error("Cannot connect." + ex);
            return null;
        }
    }
}
